#include "IL/il.h"

#ifndef __SSAO_H__
#define __SSAO_H__

class ShaderObject;
class FramebufferObject;
class Renderbuffer;

class cSSAO
{
public:
	cSSAO(int _w, int _h, unsigned int textureTarget); // window's width and height 
	~cSSAO();
	FramebufferObject *sceneFBO;
	ILuint rnm, rnm_w, rnm_h;
	ILubyte *rnm_data;
	ShaderObject *normal;
	ShaderObject *depth;
	ShaderObject *ssao;
	ShaderObject *composition;
	unsigned int depthBuffer;
	unsigned int frameBuffer;
	unsigned int depthTexture;
	unsigned int depthTexId;
	unsigned int sceneTexId;
	unsigned int normalTexId;
	unsigned int rnmTexId;
	unsigned int ssaoTexId;
	ShaderObject *displayTexRect,*displayTex2D;
	void setFBOProjection (int w, int h);
	void restoreProjection();
	void setFBORProjection (int w, int h);
	void restoreRProjection();
	void renderToNormal();
	void renderToDepth();
	void renderToSSAO();
private:	
	FramebufferObject *downSampleFBO;
	Renderbuffer *rb;
	unsigned int renderBuffer;
	unsigned int stencilBuffer;
	unsigned int downSampleTexId, finalCompTexId;
	unsigned int texTarget;
	int w,h,wDown, hDown, vp[4];		
	ShaderObject *downSampleShader;	
};

#endif __SSAO_H__